package cn.fiveinone.setting;

/**
 * @Description
 * @auther Szper
 * @create 2019-10-23 11:08
 */
public class Setting {
    public static int heartbeat = 3000; //心跳
    public static int corePoolSize = 10; //线程池
    public static int maximumPoolSize = 100; //最大线程数量
    public static long keepAliveTime = 3000;
    public static long TMOT = -1;
    public static long timeout = 2;
    public static String services = "localhost:1888,localhost:1889";
    public static String[][] getMasterConfig () {
        return getServerFromStr(services);
    }
    public static String[][] getServerFromStr (String services) {
        String[] urls = services.split(",");
        String[][] sarr = new String[urls.length][];
        for (int i = 0; i < urls.length; ++i) {
            String[] hostport = urls[i].split(":");
            sarr[i] = hostport;
        }
        return sarr;
    }
    public static int getHeartbeat() {
        return heartbeat;
    }
    public static int getCorePoolSize() {
        return corePoolSize;
    }
    public static int getMaximumPoolSize () {
        return maximumPoolSize;
    }
    public static long getKeepAliveTime () {
        return keepAliveTime;
    }
    public static String getProtocolInfo(String ym, int dk, String mc){
        return "rmi://"+ym+":"+dk+"/"+mc;
    }
    static long getSecTime(Double hours)
    {
        Double t = hours*3600*1000;
        return t.longValue();
    }
    public static long getTMOT(){
        if(TMOT==-1)
            TMOT = getSecTime(new Double(timeout));
        return TMOT;
    }
}
